const useTitleNavBar = (config: {
  color: string
  toggleColor: string
  isScrollToggle: boolean
}) => {
  const { color, toggleColor } = Object.assign(
    {
      color: '#fbdc19',
      toggleColor: '#ffffff',
      isScrollToggle: false,
    },
    config,
  );
  const bgColor = ref(color);
  return { bgColor, toggleColor, color };
}

export default useTitleNavBar;

export const titbarOpacityColorTransform = (offset: number, color: string) => {
  // 变速度系数
  const speed = 4;
  const max = 255 / speed;
  offset = offset / max;

  // 00 ~ ff
  const opacity
    = offset > 1
      ? 'ff'
      : Math.floor(offset * 255).toString(16).padStart(2, '0')

  return color + opacity;
}
